<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>绿地中央广场综合物业办公系统 - 基础表格</title>
    <meta name="keywords" content="绿地中央广场综合物业办公系统">
    <meta name="description" content="绿地中央广场综合物业办公系统">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/select/bootstrap-select.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper2 wrapper-content2 animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-3 text-right">
                    <h3><small>搜索条件:</small></h3>
                </div>
                <div class="col-sm-2">
                    <select class="selectpicker form-control">
                        <option value="0">选择类型</option>
                        <option value="1">项目名称</option>
                        <option value="2">项目经理</option>
                    </select>
                </div>

                <div class="col-sm-3">
                    <div class="input-group">
                        <input type="text" placeholder="请输入关键词" class="input-sm form-control">
                        <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary"><i
                                                class="fa fa-search"></i> 搜索</button>
                                    </span>
                    </div>

                </div>
                <div class="col-sm-2 text-right">
                    <a href="save-benchmarking.html" class="btn btn-sm btn-primary" type="button"><i
                            class="fa fa-plus-circle"></i>添加对标信息</a>
                </div>
                <div class="col-sm-2 text-right">
                    <a href="save-benchmarkingforfile.html" class="btn btn-sm btn-primary" type="button"><i
                            class="fa fa-plus-circle"></i>采集对标信息</a>
                </div>
            </div>
            <div class="hr-line-dashed2"></div>
            <div class="table-responsive">
                <table class="table table-striped list-table">
                    <thead>
                    <tr>
                        <th>选择</th>
                        <th>序号</th>
                        <th>企业名称</th>
                        <th>年营业额</th>
                        <th>企业性质</th>
                        <th>员工数量</th>
                        <th>成立时间</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>

            <div class="row">
                <div class="col-sm-5">
                    <button class="btn btn-sm btn-primary btnAll" type="button"><i class="fa fa-check-square-o"></i> 全选
                    </button>
                    <button class="btn btn-sm btn-primary btnRever" type="button"><i class="fa fa-square-o"></i> 反选
                    </button>
                    <button class="btn btn-sm btn-primary btnRemoveAll" type="button"><i
                            class="fa fa-times-circle-o"></i> 删除
                    </button>
                    <a href="/datacollect/downLoadExcel?pageNum=1" class="btn btn-sm btn-primary toexcel"><i class="fa fa-table"></i> 导出Excel
                    </a>
                </div>
                <div class="col-sm-7 text-right pageList">

                </div>
            </div>

        </div>
    </div>
</div>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/plugins/select/bootstrap-select.min.js"></script>
<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/page.js"></script>

<script>

    function loadData(pageNum) {
        if (pageNum < 1) {
            pageNum = 1;
        }
        $("tbody").html("");
        $.getJSON("/datacollect/list", {"pageNum": pageNum}, function (response) {
            globalPageNum = response.pageNum;
            globalSize = response.size;
            $(response.list).each(function () {
                let $dc = `<tr>
                                 <td><input  type="checkbox" value="` + this.id + `"></td>
                                 <td>` + this.id + `</td>
                                 <td>` + this.cname + `</td>
                                 <td>` + this.turnover + `0亿</td>
                                 <td>` + this.business + `</td>
                                 <td>` + this.employeecount + `</td>
                                 <td>` + this.buildtime + `</td>
                                 <td class="text-right">
                                   <a href="show-benchmarking.html?id=` + this.id + `" class="btn btn-primary btn-xs btnShow"><i class="fa fa-eye"></i>查看</a>
                                     <a href="update-benchmarking.html?id=` + this.id + `" class="btn btn-primary btn-xs"><i class="fa fa-edit"></i>编辑</a>
                                     <button class="btn btn-danger btn-xs btndel btnDel"><i class="fa fa-close"></i>删除</button>
                                 </td>
                                </tr>`
                $("tbody").append($dc);
            });
            page(response);
        });
    }

    function setPage(pageNum){
        $(".toexcel").prop("href","/datacollect/downLoadExcel?pageNum="+pageNum);
    }
    $(document).ready(function () {
        loadData();

        $("body").on("click", ".btnDel", function () {
            let id = $(this).parents("tr").children().eq(1).text();
            swal({
                title: "您确定要删除这条信息吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "删除",
                closeOnConfirm: false,
                cancelButtonText: "取消"
            }, function () {//此函数是点击删除执行的函数
                //这里写ajax代码
                // 以下是成功的提示框，请在ajax回调函数中执行
                $.post("/datacollect/remove", {"id": id}, function (response) {
                    if (response == "success") {
                        swal("删除成功", "删除成功", "success");
                        if (globalSize == 1) {
                            globalPageNum = globalPageNum - 1;
                        }
                        loadData(globalPageNum);
                    } else {
                        swal("删除失败", "删除成功...", "error");
                    }
                }, "text");
            });
        });
        $(".btnAll").click(function () {
            $("input:checkbox").each(function () {
                $(this).prop("checked", "checked");
            });
        });
        $(".btnRever").click(function () {
            $("input:checkbox").each(function () {
                let $prop = $(this).prop("checked");
                $(this).prop("checked", !$prop);
            });
        });

        $(".btnRemoveAll").click(function () {
            let $id = "";
            $("input:checkbox:checked").each(function () {
                $id += ","+$(this).val();
            });
            $id = $id.substring(1);
            let ids = $id.split(",");
            swal({
                title: "您确定要删除这些信息吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "删除",
                closeOnConfirm: false,
                cancelButtonText: "取消"
            }, function () {
                $.ajax({
                    type:'post',
                    url:'/datacollect/removeList',
                    async:true,
                    data:{"ids":$id},
                    traditional:true,
                    success:function (response) {
                        if (response == "success") {
                            swal("全部删除成功", "全部删除成功", "success");
                            if (ids.length==globalSize) {
                                globalPageNum = globalPageNum - 1;
                            }
                            loadData(globalPageNum);
                        } else {
                            swal("删除失败", "删除失败...", "error");
                        }
                    }
                });
            });

        });
    });
</script>

</body>


</html>
